package axdoc.rule.check.impl;

import com.alibaba.fastjson.JSONObject;

import axdoc.rule.check.AbsCheck;
import axdoc.rule.check.LoadChecksUtil;
import axdoc.util.StringUtils;

public class CheckPdeptRule extends AbsCheck {


	public CheckPdeptRule() {
		super();
	}

	public CheckPdeptRule(String pdepts) {
		this.pdepts = pdepts;
		this.cname = this.getClass().getName();
	}

	public String pdepts;

	public String getPdepts() {
		return pdepts;
	}

	public void setPdepts(String pdepts) {
		this.pdepts = pdepts;
	}

	@Override
	public boolean check(JSONObject obj) {
		String pdept = obj.getString("pdept");
		if (StringUtils.isEmpty(pdepts) || pdepts.equals("0")) {
			return true;
		} else {
			if (!pdepts.contains(pdept)) {
				LoadChecksUtil.logger.info("[校验医生科室][医生科室不匹配]");
				return false;
			} else if (StringUtils.isEmpty(pdept)) {
				LoadChecksUtil.logger.info("[校验医生科室][医生没有科室信息]");
				return false;
			}
		}
		return true;
	}

}
